package com.qf.controller;

import com.qf.pojo.Catalog;
import com.qf.service.CatalogService;
import com.qf.service.impl.CatalogServiceImpl;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

/**
 * Created by Administrator on 2021/10/19.
 */
//用于在首页面中加载所有数据
@WebServlet("/load")
public class LoadController extends BaseController {

    private CatalogService catalogService=new CatalogServiceImpl();

    public String all(HttpServletRequest request,HttpServletResponse response){

        List<Catalog> catalogList = catalogService.selectCatalogByLevel1();
        if(catalogList==null){
            //err.jsp
            return "forward:err";
        }else {
            //index.jsp正确页面，展示数据
            request.setAttribute("clist",catalogList);
            return "forward:index";
        }

    }

}
